using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using AntDesign;
using AntDesign.Charts;
using AntDesign.ProLayout;
using System.Net.Http;
using System.Net.Http.Json;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Http;
using Microsoft.JSInterop;
using ZFY.UMC.BlazorWebAssembly;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using ZFY.UMC.BlazorWebAssembly.Shared;
using Microsoft.AspNetCore.Components.Authorization;
using ZFY.Core;

namespace ZFY.UMC.BlazorWebAssembly.Components
{
    public partial class AvatarDropDown
    {
        public Menu Menu { get; set; }
        string _imgUrl;
        string _userName;
        [CascadingParameter]
        private Task<AuthenticationState> authenticationStateTask { get; set; }
        [Inject] protected NavigationManager NavigationManager { get; set; }
        [Inject]
        SignOutSessionStateManager SignOutManager { get; set; }
        [CascadingParameter]
        CurrentUserProfile CurrentUserProfile { get; set; }
        protected override async Task OnInitializedAsync()
        {

            await  base.OnInitializedAsync();
        }

        protected override async Task OnAfterRenderAsync(bool firstRender)
        {


            await base.OnAfterRenderAsync(firstRender);
        }

        async Task OnAvatarDropDownSelectAsync(MenuItem menuItem)
        {
            Console.WriteLine(menuItem.Key);
            
            switch (menuItem.Key)
            {
                case "logout":
                    await SignOutManager.SetSignOutState();
                    NavigationManager.NavigateTo("authentication/logout");
                    return;
                case "userCenter":
                    NavigationManager.NavigateTo("user/personalcenter");
                    return;
                default:
                    break;
            }
        }

        void ToUserCenter()
        {
            NavigationManager.NavigateTo("user/personalcenter");
        }
    }

}